<?php
/**
 * Galleria. True Gallery  Plugin
 * 
 * 
 * 
 * 
 */

defined('_VALID_MOS') or defined('_JEXEC') or die('Direct Access to this location is not allowed.');

$plugin_path = TG_ADMINWAY.'plugins/galleria/';
$text = '';
$text .= '<link rel="stylesheet" type="text/css" href="'.$plugin_path.'css/black.css" />'."\n";
$text .= '<script type="text/javascript" src="'.$plugin_path.'js/jquery.galleria.min.js"></script>'."\n";

$app = &JTuneConfig::getApplication();
$app->addCustomHeadTag( $text );
?>

<div class="demo">
	<ul class="gallery_demo_unstyled">
		<?php 
		$i=17;
		foreach( $rows as $picture ) {
			//$rel			= TG_THUMBSWAY.$picture->catid.'/'.$picture->imgfilename;
			$rel			= buildPictureAjaxLink($picture->id, $picture->catid, $Itemid, 2, $picture->imgfilename);
			//$img			= TG_PICTURESWAY.$picture->catid.'/'.$picture->imgfilename;
			$img			= buildPictureAjaxLink($picture->id, $picture->catid, $Itemid, 1, $picture->imgfilename);
			//$orig		= TG_ORIGINALSWAY.$picture->catid.'/'.$picture->imgfilename;
			$orig		= buildPictureAjaxLink($picture->id, $picture->catid, $Itemid, 0, $picture->imgfilename);
			
			$title			= jsspecialchars( $picture->imgtitle );
			$imgtext	= jsspecialchars( $picture->imgtext );
			
			$active = '';
			if( $picture->id == $picid ) $active = '" class="active';
			?><li><a href="<?php echo $img.$active; ?>" title="<?php echo $imgtext; ?>"><?php
			?><img src="<?php echo $rel.$active; ?>" big="<?php echo $orig; ?>" alt="<?php echo $title; ?>" /></a></li><?php
			$i--;
			if( $i<0 ) break;
		} ?>
	</ul>
	<div class="galleria_container"></div>
	<div style="clear:both"></div>
	<p class="nav"><a href="#" onclick="$j.galleria.prev(); return false;">&lt; previous</a> | <a href="#" onclick="$j.galleria.next(); return false;">next &gt;</a></p>
</div>

<!--div style="clear:both;"></div-->
<!--div class="info">
	<h2>Information</h2>
	<p></p>
</div-->

<script>
$j('.gallery_demo_unstyled').addClass('gallery_demo'); // adds new class name to maintain degradability

$j('ul.gallery_demo').galleria({
	history   : true, // activates the history object for bookmarking, back-button etc.
	clickNext : true, // helper for making the image clickable
	insert    : '#main_image', // the containing selector for our main image
	onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
		
		// fade in the image & caption
		image.css('display','none').fadeIn(1000);
		caption.css('display','none').fadeIn(1000);
		
		// fetch the thumbnail container
		var _li = thumb.parents('li');
		
		// fade out inactive thumbnail
		_li.siblings().children('img.selected').fadeTo(500,0.3);
		
		// fade in active thumbnail
		thumb.fadeTo('fast',1).addClass('selected');
		
		// add a title for the clickable image
		image.attr('title','Next image >>');
	},
	onThumb : function(thumb) { // thumbnail effects goes here
		
		// fetch the thumbnail container
		var _li = thumb.parents('li');
		
		// if thumbnail is active, fade all the way.
		var _fadeTo = _li.is('.active') ? '1' : '0.3';
		
		// fade in the thumbnail when finnished loading
		thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
		
		// hover effects
		thumb.hover(
			function() { thumb.fadeTo('fast',1); },
			function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
		)
	}
});
</script>